/**
 * 正则替换，自实现ES11语法
 * @param {*} origin 
 * @param {*} reg 
 * @param {*} func 
 */
function replaceAll(origin, reg, func){
    let r = new RegExp(reg)
    const s = origin
    let newS = ''
    for(let i = 0, len = s.length; i < len; i++){
      const o = s[i]
      if(reg.test(o)) newS += func(o, i, len)
      else newS += o
    }
    return newS
}

export { replaceAll }